import java.util.Scanner;

public class Rave {
    public static void main(String[] args) {


//        String s=scanner.nextLine();
//        int N=Integer.parseInt(s.split(" ")[0]) ;
//        int count=Integer.parseInt(s.split(" ")[1]) ;
//        int manid=Integer.parseInt(s.split(" ")[2]) ;
//
        Scanner scanner=new Scanner(System.in);
        int N=scanner.nextInt();
        int count=scanner.nextInt();
        int manid=scanner.nextInt();
        int run[][]=new int [count][2];
        int lastcorce = 0;
        Runman over[] =new Runman[N];
        for (int i = 0; i < count; i++) {
            run[i][0]=scanner.nextInt();
            run[i][1]=scanner.nextInt();
        }

        for (int i = 0; i < N; i++) {
            over[i]= new Runman(i+1);
        }

        for (int i = 0; i < run.length; i++) {
            for (Runman runman : over) {
                if(runman.id==run[i][0]){
                    runman.score++;
                }
                if(runman.id==run[i][1]){
                    runman.score--;
                }
            }

        }

        for (Runman runman : over) {
            if(runman.id==manid){
                runman.score=lastcorce;
            }
        }



        for (Runman runman : over) {
            if(runman.score==lastcorce){
                System.out.print(runman.id+" ");
            }
        }

    }

}

class Runman{
    int id;
    int score=0;

    public Runman(int id) {
        this.id = id;
    }
}
